<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\video\model;

use think\Model;

/**
 * 视频 预置评论 模型
 * @package app\user_center\model
 */
class VideoPlayCommentArtificial extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'xm_video_play_comment_artificial';

    /**
     * 添加数据
     * @param int $play_id 视频id
     * @param int $content 评论内容
     * @author shiqiang
     * @return bool
     */
    public function addData( $play_id, $content){
		$video_info = model('video/VideoPlay') -> getPlayFatherPlayInfo($play_id);
		$play_id = $video_info['data'];//关联的视频id
		
        $this -> play_id         = $play_id;
        $this -> content         = $content;
        $res = $this -> isUpdate(false) -> save();
        if($res){
            return array_out(200, 'success', $this -> id);
        }else{
            return array_out(-1001, 'error');
        }
    }

    /**
     * 删除数据
     * @param int $comment_id 评论id
     * @author shiqiang
     * @return bool
     */
    public function deleteData($comment_id){

        $res = self::destroy($comment_id);
        if($res){
            return array_out(200, 'success');
        }else{
            return array_out(-1001, 'error');
        }
    }
	
	/**
     * 视频 关联载入（一对一）
     */
    public function getVideoPlay(){
        return $this -> hasOne('app\video\model\VideoPlay','id', 'play_id');
    }
}
